/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/21 18:16
  *
  * @file       pd_i2c.h
  * @brief      Header file of I2C peripheral driver.
  *
  * @note       This file contains the I2C object declaration.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date          Author       Notes
  *   2024/6/21     Chris        the first version
  *
  ******************************************************************************
  */


#ifndef JLC_SKY_I2C_H
#define JLC_SKY_I2C_H

#include "stm32f407xx.h"
#include "pd_gpio.h"
#include "drivers.h"

typedef struct I2CDef I2C;

struct I2CDef {
    GPIO *sck;
    GPIO *sda;

    void (*init)(I2C *this);

    uint8_t (*send)(I2C *this, uint8_t salveAddress, uint16_t regAddress, uint8_t *dat, uint8_t len);

    uint8_t (*read)(I2C *this, uint8_t salveAddress, uint16_t regAddress, uint8_t *dat, uint8_t len);
};

extern const struct I2CClass {
    I2C *(*build)(GPIO *sck, GPIO *sda);
} I2CBuilder;

#endif //JLC_SKY_I2C_H
